Load Packages:
library(marmap)
library(ggrepel)
library(oce)
library(ocedata)
library(ggmap)
library(ggplot2)Specify sampling locations:
lon = c(127.782, 126.47, 126.9, 123.85, 126.91, 127.341, 129.57 )
lat = c(26.446, 26.291, 25.93, 24.86, 27.79, 29.01, 28.96)
Station = c("Okinawa", "St. 2", "St.4", "St. 10", "St.12", "St. 13", "St. 17")
pts = cbind.data.frame(lon, lat, Station)
rownames(pts) <- c("Okinawa", "St. 2", "St.4", "St. 10", "St.12", "St. 13", "St. 17")Specify map labels:
Clon = c(130.94, 120.94, 121.03, 121, 126)
Clat= c(31.93, 31, 23, 27, 22)
CLabels= c("Japan", "China", "Taiwan", "East China Sea", "Philippine Sea")
Countries = cbind.data.frame(Clon, Clat, CLabels)Define center of map:
ll_mean = c(mean(pts$lon), mean(pts$lat))Get raster background map data:
ggm = get_map(location = ll_mean, maptype = "satellite", source = "google", zoom = 6)## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=27.041,126.974714&zoom=6&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
Create map:
gg = ggmap(ggm) +
geom_point(data = pts, colour = "black", fill = "red", stroke = 1, size = 2, alpha = 0.7, shape = 21)+
ylab("Longitude")+xlab("Latitude") + geom_text_repel(data = pts, aes(x = lon, y = lat, label = Station),
size = 5, vjust = 0, hjust = -0.15, color = "white", family= "Times New Roman")+
geom_text(data =Countries, aes(x=Clon, y = Clat, label = CLabels),
size = 6, vjust = 0, hjust = -0.1, color = "white", family= "Times New Roman", fontface = "bold")+
theme(text=element_text(size=16, family="serif")) ggSave map:
#ggsave("~/desktop/newmapA.png", gg, device= "png")Specify sampling location:
lon = c(-118.49)
lat = c(33.45)
Station = c("Catalina")
pts = cbind.data.frame(lon, lat, Station)Specify map labels:
Clon = c(-120.5, -118.7, -120.5)
Clat= c(35, 34.1, 32.9)
CLabels= c("California, U.S.A.", "Los Angeles", "Pacific Ocean")
Countries = cbind.data.frame(Clon, Clat, CLabels)Get raster background map data:
ggm = get_map(location = c(lon=-119, lat=34), maptype = "satellite", source = "google", zoom = 8)## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=34,-119&zoom=8&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
Create map:
ggB = ggmap(ggm) +
geom_point(data = pts, colour = "black", fill = "red", stroke = 1, size = 2, alpha = 0.7, shape = 21)+
ylab("Longitude")+xlab("Latitude") + geom_text_repel(data = pts, aes(x = lon, y = lat, label = Station),
size = 5, vjust = 0, hjust = -0.15, color = "white", family= "Times New Roman")+
geom_text(data =Countries, aes(x=Clon, y = Clat, label = CLabels),
size = 6, vjust = 0, hjust = -0.15, color = "white", family= "Times New Roman", fontface = "bold")+
theme(text=element_text(size=16, family="serif")) ggBSave map:
#ggsave("~/desktop/newmapB.png", ggB, device= "png")